package indi.luckly.controller;

import indi.luckly.common.request.LoginRequestParams;
import indi.luckly.common.request.LogoutRequestParams;
import indi.luckly.common.request.RegisterRequestParams;
import indi.luckly.common.response.LoginResponseData;
import indi.luckly.common.response.LogoutResponseData;
import indi.luckly.common.response.RegisterResponseData;
import indi.luckly.common.response.ResponseResult;
import indi.luckly.entity.UserEntity;
import indi.luckly.service.ILoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    @Qualifier(value = "LoginService")
    ILoginService mLoginService;

    @PostMapping
    @RequestMapping(path = "/register", method = RequestMethod.POST)
    public ResponseResult<RegisterResponseData> register(@RequestBody RegisterRequestParams registerRequestParams) {
        return mLoginService.register(registerRequestParams);
    }

    @PostMapping
    @RequestMapping(path = "/login", method = RequestMethod.POST)
    public ResponseResult<LoginResponseData> login(@RequestBody LoginRequestParams loginRequestParams) {
        return mLoginService.login(loginRequestParams);
    }

    @PostMapping
    @RequestMapping(path = "/logout", method = RequestMethod.POST)
    public ResponseResult<LogoutResponseData> logout(@RequestBody LogoutRequestParams logoutRequestParams) {
        return mLoginService.logout(logoutRequestParams);
    }


    public ResponseResult<UserEntity> queryUserInfo() {
        //  mUserService.queryUserInfo()
        return null;
    }

}
